//引入路由
import router from "./index";

//获取vuex数据（token）
import store from "../store/index"

//首页的路由拦截
router.beforeEach((to, from, next) => {
  // console.log(to);
  //判断是否需要登录
  if(to.matched.some(ele=>ele.meta.isLogin)){
    //判断用户是否已经登录
    let token = store.state.longinModule.userinfo.token;//token赋值
    if(token){
      next()
    }else{
      next("/login")
    }
  }
  else{
    next()
  }
});